<template>
  <div class="home flex-row">
    <template>
      <router-view ref="page" />
    </template>
  </div>
</template>

<script>
// @ is an alias to /src
export default {
  name: 'Home',
  components: {
  },
  data() {
    return {
      theme: {},
      lightTheme: {},
      darkTheme: {},
      themeList: [{
        name: '浅色',
        value: 'light'
      }, {
        name: '深色',
        value: 'dark'
      }]
    }
  },
  watch: {
    theme(val) {
      if (val.value === 'light') {
        this.utils.saveStorage('theme', 'light')
        this.Bus.theme = 'light'
        for (const key in this.lightTheme) {
          document.body.style.setProperty(key, this.lightTheme[key])
        }
      } else if (val.value === 'dark') {
        this.utils.saveStorage('theme', 'dark')
        this.Bus.theme = 'dark'
        for (const key in this.darkTheme) {
          document.body.style.setProperty(key, this.darkTheme[key])
        }
      }
      if (this.$route.meta.isPC) {
        // this.$refs.page.initTheme()
      }
    }
  },
  created() {
    // this.init()
  },
  mounted() {
    this.init()
  },
  methods: {
    init() {
      const theme = this.utils.getStorage('theme') || 'light'
      if (theme === 'dark') {
        this.theme = {
          name: '深色',
          value: 'dark'
        }
      } else {
        this.theme = {
          name: '浅色',
          value: 'light'
        }
      }
      this.lightTheme = {
        '--bg-color-page': '#fff',
        '--bg-color-button': '#4065E0',
        '--bg-color-button-other': '#1ABC8D',
        '--bg-color-panel': '#fff',
        '--bg-color-selectbox': '#fff',
        '--bg-color-radioCheckbox': '#fff',
        '--bg-color-panel-selected': '#ddd',
        '--bg-color-disabled': '#f7f7f7',
        '--bg-color-menu': '#4065E0',
        '--bg-color-menu-selected': '#3552BA',
        '--border-color-panel': '#ddd',
        '--border-color-panel-shadow': '#fff',
        '--border-color-panel-header': '#ddd',
        '--border-color-panel-list': '#aaa',
        '--border-color-selectbox': '#E6E6E6',
        '--border-color-radio': '#8d8d8d',
        '--border-color-checkbox': '#8d8d8d',
        '--border-color-menu': '#4065E0',
        '--border-color-menu-selected': '#30FFCF',
        '--font-color-button': '#fff',
        '--font-color-input': '#333',
        '--font-color-default': '#333',
        '--font-color-placeholder': '#aaa',
        '--font-color-panel-label': '#777',
        '--font-color-menu': '#fff',
        '--font-color-menu-selected': '#fff'
      }
      this.darkTheme = {
        '--bg-color-page': '#000',
        '--bg-color-button': '#01DEF7',
        '--bg-color-button-other': '#1ABC8D',
        '--bg-color-panel': '#141D27',
        '--bg-color-selectbox': '#262E43',
        '--bg-color-radioCheckbox': '#fff',
        '--bg-color-panel-selected': '#1f2431',
        '--bg-color-disabled': '#1f2431',
        '--bg-color-menu': '#141D27',
        '--bg-color-menu-selected': '#262E43',
        '--border-color-panel': '#01DEF7',
        '--border-color-panel-shadow': 'rgba(1, 222, 247, 0.50)',
        '--border-color-panel-header': '#777',
        '--border-color-panel-list': '#999',
        '--border-color-selectbox': '#262E43',
        '--border-color-radio': '#8d8d8d',
        '--border-color-checkbox': '#8d8d8d',
        '--border-color-menu': '#141D27',
        '--border-color-menu-selected': '#01DEF7',
        '--font-color-button': '#fff',
        '--font-color-input': '#fff',
        '--font-color-default': '#01DEF7',
        '--font-color-placeholder': '#aaa',
        '--font-color-panel-label': '#777',
        '--font-color-menu': '#fff',
        '--font-color-menu-selected': '#01DEF7'
      }
      // this.$refs.page.initTheme()
    },
    menuChange() {
      // this.$nextTick(() => {
      //   this.$refs.page.init()
      //   this.$refs.page.initTheme()
      // })
    }
  }
}
</script>
<style lang="less">
  .home {
    width: 100%;
    height: 100%;
    // overflow: scroll;
    position: relative;
    // background-image: url('../../public/img/img_bg.png')
  }
  .change-theme {
    width: 160px;
    font-size: 14px;
    position: absolute;
    right: 10px;
    top: 10px;
    line-height: 30px;
    background-color: var(--bg-color-panel);
    justify-content: space-between;
    padding: 5px 10px;
    border-radius: 4px;
    border: 2px solid var(--border-color-panel);
    box-shadow: inset -7px -7px 10px 0 var(--border-color-panel-shadow), inset 7px 7px 10px 0 var(--border-color-panel-shadow);
    .palm-select {
      margin: 0;
    }
  }
</style>
